from django.conf.urls.defaults import *
from django.conf import settings
from django.views.generic.simple import redirect_to
from nameremoved.feeds import LatestEntries
from nameremoved.sitemap import sitemaps

feeds = {
    'feedburner': LatestEntries,
}

urlpatterns = patterns('',
    (r'^$', 'nameremoved.comics.views.index'),
    (r'^randomimage/', include('nameremoved.random_image.urls')),
    (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
        {'feed_dict': feeds}),
    (r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap',
        {'sitemaps': sitemaps}),
    (r'^comics/', include('nameremoved.comics.urls')),
    (r'^extra/', include('nameremoved.extra.urls')),
    (r'^contribute/', include('nameremoved.comics.contrib_urls')),
    (r'^admin/comics/report/$', 'nameremoved.comics.admin_views.report'),
    (r'^admin/comics/viewimage/(\d+)/', 'nameremoved.comics.admin_views.view_comic_image'),
    (r'^admin/', include('django.contrib.admin.urls')),
)

# http://www.djangosnippets.org/snippets/193/
redirects = (
    (r'^index.php', '/'),
    (r'^feed/rss.xml$', "http://feeds.feedburner.com/NameRemoved"),
    (r'^feeds/latest/$', "http://feeds.feedburner.com/NameRemoved"),
)

for oldurl, newurl in redirects:
    urlpatterns += patterns('',(oldurl,redirect_to,{'url':newurl}))

if settings.DEBUG:
    urlpatterns += patterns('',
        (r'^static/(?P<path>.*$)', 'django.views.static.serve',
            {'document_root': settings.MEDIA_ROOT + 'static'}),
        (r'^pix/(?P<path>.*$)', 'django.views.static.serve',
            {'document_root': settings.MEDIA_ROOT + 'pix'}),
        (r'^comic_images/(?P<path>.*$)', 'django.views.static.serve',
            {'document_root': settings.MEDIA_ROOT + 'comics'}),
    )
